package cn.jjxx.modules.record.entity;

import cn.jjxx.core.common.entity.AbstractEntity;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.framework.superutil.thirdparty.excel.Excel;
import cn.jjxx.modules.sys.entity.User;

import java.lang.reflect.Field;
import java.util.*;

/**   
 * @Title: 党员发展
 * @Description: 党员发展
 * @author zx
 * @date 2021-01-04 13:46:13
 * @version V1.0   
 *
 */
@TableName("development_of_members")
@SuppressWarnings("serial")
public class DevelopmentOfMembers extends AbstractEntity<String> {

    /**字段主键*/
    @Excel(name="字段主键")
    @TableId(value = "id", type = IdType.UUID)
	private String id;
    /**组织Id*/
    @Excel(name="组织Id")
    @TableField(value = "org_id")
	private String orgId;
    /**状态（0：保存；1：提交；2：审核中；3：已审核；5：打回）*/
    @Excel(name="状态（0：保存；1：提交；2：审核中；3：已审核；5：打回）")
    @TableField(value = "status")
	private Integer status;
    /**创建者*/
    @Excel(name="创建者")
    @TableField(value = "create_by",el="createBy.id",fill = FieldFill.INSERT)
	private User createBy;
    /**创建时间*/
    @Excel(name="创建时间")
    @TableField(value = "create_date",fill = FieldFill.INSERT)
	private Date createDate;
    /**更新者*/
    @Excel(name="更新者")
    @TableField(value = "update_by",el="updateBy.id",fill = FieldFill.UPDATE)
	private User updateBy;
    /**更新时间*/
    @Excel(name="更新时间")
    @TableField(value = "update_date",fill = FieldFill.UPDATE)
	private Date updateDate;
    /**删除标记（0：正常；1：删除）*/
    @Excel(name="删除标记（0：正常；1：删除）")
    @TableField(value = "del_flag")
	private String delFlag;
    /**备注信息*/
    @Excel(name="备注信息")
    @TableField(value = "remarks")
	private String remarks;
    /**入党申请人*/
    @Excel(name="入党申请人")
    @TableField(value = "applicants_party")
	private String applicantsParty;
    /**入党积极分子*/
    @Excel(name="入党积极分子")
    @TableField(value = "party_activists")
	private String partyActivists;
    /**发展对象*/
    @Excel(name="发展对象")
    @TableField(value = "development_target")
	private String developmentTarget;
    /**预备党员*/
    @Excel(name="预备党员")
    @TableField(value = "probationary_member")
	private String probationaryMember;
    /**正式党员*/
    @Excel(name="正式党员")
    @TableField(value = "formal_member")
	private String formalMember;
    /**更新时间*/
    @Excel(name="更新时间")
    @TableField(value = "update_time")
	private String updateTime;

    /**总数*/
    @TableField(exist = false)
	private String allnum;

	public static DevelopmentOfMembers fromObject(Object obj){
		DevelopmentOfMembers entity = new DevelopmentOfMembers();
		BiMap<String,String> protocol = HashBiMap.create();
		protocol.put("applicantsParty","申请人");
		protocol.put("partyActivists","积极分子");
		protocol.put("developmentTarget","发展对象");
		protocol.put("probationaryMember","预备党员");
		protocol.put("formalMember","正式党员");
		protocol = protocol.inverse();
		List<Object> list = (List<Object>)obj;
		for(Object o :list){
			Map<String,String> map = (Map<String,String>)o;
			String label = map.get("stage");
			String filed = protocol.get(label);
			if(filed!=null){
				try {
					Field f = entity.getClass().getDeclaredField(filed);
					f.setAccessible(true);
					f.set(entity,String.valueOf(map.get("num")));
				} catch (NoSuchFieldException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				}
			}
		}
		return entity;
	}

	public List<Map<String,Object>> toJsonObject(){
		List<Map<String,Object>> obj = new ArrayList<>();
		BiMap<String,String> protocol = HashBiMap.create();
		protocol.put("applicantsParty","申请人");
		protocol.put("partyActivists","积极分子");
		protocol.put("developmentTarget","发展对象");
		protocol.put("probationaryMember","预备党员");
		protocol.put("formalMember","正式党员");
		for(String filedName : protocol.keySet()){
			try {
				Field field = getClass().getDeclaredField(filedName);
				String value = field.get(this).toString();
				Map<String,Object> map = new HashMap<>();
				map.put("num",Integer.parseInt(value));
				map.put("stage",protocol.get(filedName));
				obj.add(map);
			} catch (NoSuchFieldException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return obj;
	}

	/**
	 * 获取  id
	 *@return: String  字段主键
	 */
	public String getId(){
		return this.id;
	}

	/**
	 * 设置  id
	 *@param: id  字段主键
	 */
	public void setId(String id){
		this.id = id;
	}
	/**
	 * 获取  orgId
	 *@return: String  组织Id
	 */
	public String getOrgId(){
		return this.orgId;
	}

	/**
	 * 设置  orgId
	 *@param: orgId  组织Id
	 */
	public void setOrgId(String orgId){
		this.orgId = orgId;
	}
	/**
	 * 获取  status
	 *@return: Integer  状态（0：保存；1：提交；2：审核中；3：已审核；5：打回）
	 */
	public Integer getStatus(){
		return this.status;
	}

	/**
	 * 设置  status
	 *@param: status  状态（0：保存；1：提交；2：审核中；3：已审核；5：打回）
	 */
	public void setStatus(Integer status){
		this.status = status;
	}
	/**
	 * 获取  createBy
	 *@return: User  创建者
	 */
	public User getCreateBy(){
		return this.createBy;
	}

	/**
	 * 设置  createBy
	 *@param: createBy  创建者
	 */
	public void setCreateBy(User createBy){
		this.createBy = createBy;
	}
	/**
	 * 获取  createDate
	 *@return: Date  创建时间
	 */
	public Date getCreateDate(){
		return this.createDate;
	}

	/**
	 * 设置  createDate
	 *@param: createDate  创建时间
	 */
	public void setCreateDate(Date createDate){
		this.createDate = createDate;
	}
	/**
	 * 获取  updateBy
	 *@return: User  更新者
	 */
	public User getUpdateBy(){
		return this.updateBy;
	}

	/**
	 * 设置  updateBy
	 *@param: updateBy  更新者
	 */
	public void setUpdateBy(User updateBy){
		this.updateBy = updateBy;
	}
	/**
	 * 获取  updateDate
	 *@return: Date  更新时间
	 */
	public Date getUpdateDate(){
		return this.updateDate;
	}

	/**
	 * 设置  updateDate
	 *@param: updateDate  更新时间
	 */
	public void setUpdateDate(Date updateDate){
		this.updateDate = updateDate;
	}
	/**
	 * 获取  delFlag
	 *@return: String  删除标记（0：正常；1：删除）
	 */
	public String getDelFlag(){
		return this.delFlag;
	}

	/**
	 * 设置  delFlag
	 *@param: delFlag  删除标记（0：正常；1：删除）
	 */
	public void setDelFlag(String delFlag){
		this.delFlag = delFlag;
	}
	/**
	 * 获取  remarks
	 *@return: String  备注信息
	 */
	public String getRemarks(){
		return this.remarks;
	}

	/**
	 * 设置  remarks
	 *@param: remarks  备注信息
	 */
	public void setRemarks(String remarks){
		this.remarks = remarks;
	}
	/**
	 * 获取  applicantsParty
	 *@return: String  入党申请人
	 */
	public String getApplicantsParty(){
		return this.applicantsParty;
	}

	/**
	 * 设置  applicantsParty
	 *@param: applicantsParty  入党申请人
	 */
	public void setApplicantsParty(String applicantsParty){
		this.applicantsParty = applicantsParty;
	}
	/**
	 * 获取  partyActivists
	 *@return: String  入党积极分子
	 */
	public String getPartyActivists(){
		return this.partyActivists;
	}

	/**
	 * 设置  partyActivists
	 *@param: partyActivists  入党积极分子
	 */
	public void setPartyActivists(String partyActivists){
		this.partyActivists = partyActivists;
	}
	/**
	 * 获取  developmentTarget
	 *@return: String  发展对象
	 */
	public String getDevelopmentTarget(){
		return this.developmentTarget;
	}

	/**
	 * 设置  developmentTarget
	 *@param: developmentTarget  发展对象
	 */
	public void setDevelopmentTarget(String developmentTarget){
		this.developmentTarget = developmentTarget;
	}
	/**
	 * 获取  probationaryMember
	 *@return: String  预备党员
	 */
	public String getProbationaryMember(){
		return this.probationaryMember;
	}

	/**
	 * 设置  probationaryMember
	 *@param: probationaryMember  预备党员
	 */
	public void setProbationaryMember(String probationaryMember){
		this.probationaryMember = probationaryMember;
	}
	/**
	 * 获取  formalMember
	 *@return: String  正式党员
	 */
	public String getFormalMember(){
		return this.formalMember;
	}

	/**
	 * 设置  formalMember
	 *@param: formalMember  正式党员
	 */
	public void setFormalMember(String formalMember){
		this.formalMember = formalMember;
	}
	/**
	 * 获取  updateTime
	 *@return: String  更新时间
	 */
	public String getUpdateTime(){
		return this.updateTime;
	}

	/**
	 * 设置  updateTime
	 *@param: updateTime  更新时间
	 */
	public void setUpdateTime(String updateTime){
		this.updateTime = updateTime;
	}

	public String getAllnum() {
		return allnum;
	}

	public void setAllnum(String allnum) {
		this.allnum = allnum;
	}


	
}
